﻿using UnityEngine;
using System.Collections.Generic;

public class ZoneRender
{
    public static int OrderMaxNumber = 5;

    public ZoneRender()
    {

    }

    public void Order()
    {
        //Order((int)nLayerOrder.Groud, ZoneManager._Groud);
        ZoneManager._FoundationLayer.SetSortingOrder((int)nLayerOrder.Foundation);
        ZoneManager._BuildingLayer.SetSortingOrder((int)nLayerOrder.Building);
        ZoneManager._DecoLayer.SetSortingOrder((int)nLayerOrder.Decos);
        ZoneManager._WallLayer.SetSortingOrder((int)nLayerOrder.Decos);

        //OrderParts();
    }

    //#region 排序
    //void OrderParts()
    //{
    //    for (int i = 0; i < ((LayerObject)ZoneManager._Groud[0])._grid_blocks.Length; ++i)
    //    {
    //        TogetherOrder(i);
    //    }
    //}

    //public void TogetherOrder(int order)
    //{
    //    List<ObjectBase> walls = new List<ObjectBase>();
    //    List<ObjectBase> decos = new List<ObjectBase>();

    //    GetObject(order, ref walls, ref decos);

    //    OrderObjects(order, ref walls, decos);
    //}

    ///// <summary>
    ///// 纵向排序
    ///// </summary>
    ///// <param name="uos"></param>
    //void OrderObjects(int order, ref List<ObjectBase> walls, List<ObjectBase> decos)
    //{
    //    if (decos.Count >= ZoneRender.OrderMaxNumber)
    //    {
    //        Debug.LogError("ZoneRender.OrderObjects > " + ZoneRender.OrderMaxNumber);
    //    }

    //    int order_4_sortingOrder = order * ZoneRender.OrderMaxNumber;

    //    decos.Sort(new DecoObjectCompare());

    //    for (int i = 0; i < walls.Count; ++i)
    //    {
    //        UnitObject uo = (UnitObject)walls[i];
    //        uo.SetSortingOrder((int)nLayerOrder.Decos - order_4_sortingOrder++);
    //    }

    //    for (int i = 0; i < decos.Count; ++i)
    //    {
    //        UnitObject uo = (UnitObject)decos[i];
    //        uo.SetSortingOrder((int)nLayerOrder.Decos - order_4_sortingOrder++);
    //    }

    //}

    ///// <summary>
    ///// 获取该order有哪些东西
    ///// </summary>
    ///// <param name="order"></param>
    //bool GetObject(int order, ref List<ObjectBase> walls, ref List<ObjectBase> decos)
    //{
    //    walls.Clear();
    //    decos.Clear();

    //    walls.AddRange(ZoneManager._WallLayer._Foundation);
    //    decos.AddRange(ZoneManager._DecoLayer._Foundation);

    //    return true;
    //}
    //#endregion

    #region 装饰物排序

    //class DecoObjectCompare : IComparer<ObjectBase>
    //{
    //    public int Compare(ObjectBase a, ObjectBase b)
    //    {
    //        return a._rgc._Data._sec.CompareTo(b._rgc._Data._sec);
    //    }
    //}
    #endregion
}
